//
//  UsedTool.m
//  HappyStore
//
//  Created by 李小辉 on 16/6/12.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "UsedTool.h"

@implementation UsedTool



/**
 * 时间转换成星期几
 */
+ (NSString *)getWeekDayForstring:(NSString *)dataString{
    
    NSDateFormatter *currentDateFormat = [[NSDateFormatter alloc]init];
    //时区
    NSTimeZone *currentDateTimeZone = [NSTimeZone defaultTimeZone];
    [currentDateFormat setTimeZone:currentDateTimeZone];
    //将字符串按formatter转成nsdate
    [currentDateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
    NSDate *destDate = [currentDateFormat dateFromString:dataString];
    
    
    NSArray *weekday = [NSArray arrayWithObjects: [NSNull null], @"周日", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    
    NSDateComponents *components = [calendar components:NSWeekdayCalendarUnit fromDate:destDate];
    NSString *weekStr = [weekday objectAtIndex:components.weekday];
    return weekStr;
}




/**
 * 薪资转换
 */
+ (NSString *)moneyChange:(NSString *)string{
    NSInteger num = [string integerValue];
    switch (num) {
        case 0:
            return @"面议";
            break;
        case 500:
            return @"1K以下";
            break;
        case 2000:
            return @"1K~3K";
            break;
        case 4000:
            return @"3K~5K";
            break;
        case 6000:
            return @"5K~7K";
            break;
        case 8000:
            return @"7K~9K";
            break;
        case 12000:
            return @"10K~15K";
            break;
        case 18000:
            return @"15K~30K";
            break;
        case 30000:
            return @"30K以上";
            break;
            
        default:
            break;
    }
    return @"面议";
}



/**
 * 找资金金额转换
 */
+ (NSString *)priceChange:(NSString *)string{
    NSInteger num = [string floatValue];
    if (num <= 1000000) {
        return @"100万以下";
    }else if (num > 1000000 && num <= 5000000){
        
        return @"100~500万";
        
    }else if (num > 5000000 && num <= 10000000){
        
        return @"500~1000万";
        
    }else if (num > 10000000 && num <= 50000000){
        
        return @"1000~5000万";
        
    }else if (num > 5000000 && num <= 100000000){
        
        return @"5000万~1亿";
        
    }else if (num > 100000000 && num <= 500000000){
        
        return @"1~5亿";
        
    }else if (num > 500000000 && num <= 1000000000){
        
        return @"5~10亿";
        
    }else if (num > 1000000000){
        
        return @"10亿以上";
    }
    
   return @"";
}

//        aryMoneyData = @[@"100万以下",@"100~500万",@"500~1000万",@"1000~5000万",
//                         @"5000万~1亿",@"1~5亿",@"5~10亿",@"10亿以上"];

//100,300,700,3000,7000,30000,70000,100000

/**
 *判断上级
 */
+ (NSString *)userType:(NSString *)userType companyName:(NSString *)companyName userAddress:(NSString *)userAddress{
    //判断上级
    if ([userType integerValue] == 1) {//个人
        //先判断公司
        if ([companyName isEqualToString:@"null"] || [companyName isEqualToString:@""] || companyName == nil) {
            //判断地址
            if ([userAddress isEqualToString:@"null"] || [userAddress isEqualToString:@""] ||userAddress == nil) {
                return @" ";
            }else{
                return userAddress;
            }
        }else{
            return companyName;
        }
    }else {//企业 or 政府
        //判断地址
        if ([userAddress isEqualToString:@"null"] || [userAddress isEqualToString:@""] ||userAddress == nil) {
            return @" ";
        }else{
            return userAddress;
        }

    }
}



/**
 *判断会员等级
 */
+ (UIImage *)setVipimage:(NSString *)vipLevel{
    
    if (vipLevel == nil || [vipLevel isEqualToString:@""] || [vipLevel isEqualToString:@"null"]) {//判断是否 为空
        return nil;
    }else if ([vipLevel integerValue] == 0){//不是会员
        return nil;
    }else if ([vipLevel integerValue] == 1){//会员1
        return [UIImage imageNamed:@"会员-v1"];
    }else
        return nil;
}
/**
 *判断是否已认证;未认证就隐藏
 */
+ (BOOL)authStateImageViewHidden:(NSString *)authState{
    if ([authState integerValue] == 2) {
        return NO;
    }else{
        return YES;
    }
}

@end
